﻿-- Ajout de la colonne LastContextUsed à la table Localizations qui permet de concerver le dernier context où la traduction a été utilisée.
IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Localizations' AND COLUMN_NAME = 'LastContextUsed')
BEGIN
   ALTER TABLE Localizations ADD LastContextUsed nvarchar(500)
END

-- Ajout des clés de traductions pour le nouveau champ ResourceLastContext
if (not exists(Select null from Localizations where ResourceId = 'LastContext' and ResourceSet = 'medianamik_resourcemanagement' and LocaleId = 'en-ca'))
begin
	INSERT INTO [Localizations]
           ([ResourceId]
           ,[Value]
           ,[LocaleId]
           ,[ResourceSet])
     VALUES
           ('LastContext'
           ,'Last context of resource'
           ,'en-ca'
           ,'medianamik_resourcemanagement')
end

if (not exists(Select null from Localizations where ResourceId = 'LastContext' and ResourceSet = 'medianamik_resourcemanagement' and LocaleId = 'fr-ca'))
begin
	INSERT INTO [Localizations]
           ([ResourceId]
           ,[Value]
           ,[LocaleId]
           ,[ResourceSet])
     VALUES
           ('LastContext'
           ,'Dernier contexte d''utilisation de la ressource'
           ,'fr-ca'
           ,'medianamik_resourcemanagement')
end

--Ajout de la colonne CreatedBy sur la table des publications
if not Exists(select * from sys.columns where Name = N'CreatedBy'  
                and Object_ID = Object_ID(N'medianamik_Publication'))
begin
ALTER TABLE dbo.medianamik_Publication
 ADD CreatedBy  nvarchar(50)
end

--Ajout de la sproc medianamik_GetNodePublications
If  exists (Select * from sysobjects where xtype='p' and name='medianamik_GetNodePublications')
	exec('ALTER PROCEDURE [dbo].[medianamik_GetNodePublications]
		@NodeId UNIQUEIDENTIFIER , 
		@CultureName NVARCHAR(10)
	AS
	BEGIN
		SET NOCOUNT ON;

		select pub.PublicationId, pub.DateStartOfPublication, pub.DateEndOfPublication, npv.Revision, pub.CreatedBy
				from medianamik_nodepropertyvalue as npv
				inner join dbo.medianamik_Publication as pub on npv.Revision = pub.Revision
				where npv.nodeid= @NodeId
				AND npv.culturename in (@CultureName,'''')
				AND npv.Revision IS NOT NULL
				group by pub.PublicationId, npv.NodeId, npv.Revision, pub.DateStartOfPublication, pub.DateEndOfPublication, pub.CreatedBy
				order by npv.Revision DESC
	END')
ELSE
	exec('CREATE PROCEDURE [dbo].[medianamik_GetNodePublications]
			@NodeId UNIQUEIDENTIFIER , 
			@CultureName NVARCHAR(10)
		AS
		BEGIN
			SET NOCOUNT ON;

			select pub.PublicationId, pub.DateStartOfPublication, pub.DateEndOfPublication, npv.Revision, pub.CreatedBy
				from medianamik_nodepropertyvalue as npv
				inner join dbo.medianamik_Publication as pub on npv.Revision = pub.Revision
				where npv.nodeid= @NodeId
				AND npv.culturename in (@CultureName,'''')
				AND npv.Revision IS NOT NULL
				group by pub.PublicationId, npv.NodeId, npv.Revision, pub.DateStartOfPublication, pub.DateEndOfPublication, pub.CreatedBy
				order by npv.Revision DESC
		END')
GRANT EXECUTE ON dbo.medianamik_GetNodePublications  TO medianamik_dataaccess 

--Ajout de la page PurgeLogsWindow.aspx
IF NOT EXISTS( SELECT NULL  FROM medianamik_Node where NodeId = '3743EEB0-417D-447D-9B77-F13D54F9A5DB')  BEGIN  INSERT INTO [dbo].[medianamik_Node]             ([NodeId]             ,[ParentNodeId]             ,[ContentNodeId]             ,[TypeId]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             ,[Flags]             ,[IsDeleted]             ,[Path]             ,[Depth]             ,[Position]             ,[Roles])       VALUES             ('3743EEB0-417D-447D-9B77-F13D54F9A5DB'             ,'7A6A4803-1D66-40F5-8DAB-76AFDAE93CF0'             ,NULL             ,'3DAD4D08-B9BC-4603-A8DE-42A88A354B5B'             ,'2009-04-02 16:16:18.473'             ,'sa'             ,'2009-04-02 16:16:18.473'             ,'sa'             ,         0             ,         0             ,'.7A6A4803-1D66-40F5-8DAB-76AFDAE93CF0.3743EEB0-417D-447D-9B77-F13D54F9A5DB.'             ,         1             ,         0             ,'')  END
IF NOT EXISTS(SELECT NULL FROM Medianamik_NodeInstance WHERE NodeId = '3743EEB0-417D-447D-9B77-F13D54F9A5DB' AND CultureNAme = 'fr-CA')  BEGIN  INSERT INTO [dbo].[medianamik_NodeInstance]             ([NodeInstanceId]             ,[NodeId]             ,[IsActive]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             ,[CultureName])       VALUES             ('8C3E95AB-9B5D-4EFE-B31B-40432AC03E9C'             ,'3743EEB0-417D-447D-9B77-F13D54F9A5DB'             ,         1             ,'2009-04-02 16:16:18.473'             ,'sa'             ,'2009-04-02 16:16:18.473'             ,'sa'             ,'fr-CA')  END
IF NOT EXISTS(SELECT NULL FROM Medianamik_NodeInstance WHERE NodeId = '3743EEB0-417D-447D-9B77-F13D54F9A5DB' AND CultureNAme = 'en-CA')  BEGIN  INSERT INTO [dbo].[medianamik_NodeInstance]             ([NodeInstanceId]             ,[NodeId]             ,[IsActive]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             ,[CultureName])       VALUES             ('8C956D8A-305D-4728-9CBA-F8AF56465CD5'             ,'3743EEB0-417D-447D-9B77-F13D54F9A5DB'             ,         1             ,'2009-04-02 16:16:18.473'             ,'sa'             ,'2009-04-02 16:16:18.473'             ,'sa'             ,'en-CA')  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = '3743EEB0-417D-447D-9B77-F13D54F9A5DB' AND PropertyId = 'A9D96D60-4E0D-4EF6-831C-AAD02A1D2BCF' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'3743EEB0-417D-447D-9B77-F13D54F9A5DB'             ,'A9D96D60-4E0D-4EF6-831C-AAD02A1D2BCF'             ,'False'             ,         0             ,         0             ,null             ,''             ,'2009-04-02 16:16:18.487'             ,'sa'             ,'2009-04-02 16:16:18.487'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = '3743EEB0-417D-447D-9B77-F13D54F9A5DB' AND PropertyId = 'A5F1D87F-3086-4CEA-A983-A09D4FE9FC4C' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'3743EEB0-417D-447D-9B77-F13D54F9A5DB'             ,'A5F1D87F-3086-4CEA-A983-A09D4FE9FC4C'             ,NULL             ,         0             ,         0             ,null             ,''             ,'2009-04-02 16:16:18.487'             ,'sa'             ,'2009-04-02 16:16:18.487'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = '3743EEB0-417D-447D-9B77-F13D54F9A5DB' AND PropertyId = '60C0AA24-C355-4722-ACAA-21D363351479' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'3743EEB0-417D-447D-9B77-F13D54F9A5DB'             ,'60C0AA24-C355-4722-ACAA-21D363351479'             ,NULL             ,         0             ,         0             ,null             ,''             ,'2009-04-02 16:16:18.487'             ,'sa'             ,'2009-04-02 16:16:18.487'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = '3743EEB0-417D-447D-9B77-F13D54F9A5DB' AND PropertyId = '7213C44C-BBC7-4095-AE52-0DE37E7276C7' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'3743EEB0-417D-447D-9B77-F13D54F9A5DB'             ,'7213C44C-BBC7-4095-AE52-0DE37E7276C7'             ,'False'             ,         0             ,         0             ,null             ,''             ,'2009-04-02 16:16:18.487'             ,'sa'             ,'2009-04-02 16:16:18.487'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = '3743EEB0-417D-447D-9B77-F13D54F9A5DB' AND PropertyId = '47096ACE-4C51-4C8F-BAE2-15A6FD90F6E9' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'3743EEB0-417D-447D-9B77-F13D54F9A5DB'             ,'47096ACE-4C51-4C8F-BAE2-15A6FD90F6E9'             ,'/ModalWindows/PurgeLogsWindow.aspx'             ,         0             ,         0             ,null             ,''             ,'2009-04-02 16:16:18.487'             ,'sa'             ,'2009-04-02 16:16:18.487'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = '3743EEB0-417D-447D-9B77-F13D54F9A5DB' AND PropertyId = '29571C7C-3B7A-4576-8BB0-F2EAF8413D20' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'3743EEB0-417D-447D-9B77-F13D54F9A5DB'             ,'29571C7C-3B7A-4576-8BB0-F2EAF8413D20'             ,'False'             ,         0             ,         0             ,null             ,''             ,'2009-04-02 16:16:18.487'             ,'sa'             ,'2009-04-02 16:16:18.487'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = '3743EEB0-417D-447D-9B77-F13D54F9A5DB' AND PropertyId = '18232ABC-5DD8-4AE5-947A-16F3AF3A8715' AND CultureName = 'en-CA' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'3743EEB0-417D-447D-9B77-F13D54F9A5DB'             ,'18232ABC-5DD8-4AE5-947A-16F3AF3A8715'             ,'Log purge'             ,         0             ,         0             ,null             ,'en-CA'             ,'2009-04-02 16:16:18.487'             ,'sa'             ,'2009-04-02 16:16:18.487'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = '3743EEB0-417D-447D-9B77-F13D54F9A5DB' AND PropertyId = '18232ABC-5DD8-4AE5-947A-16F3AF3A8715' AND CultureName = 'fr-CA' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'3743EEB0-417D-447D-9B77-F13D54F9A5DB'             ,'18232ABC-5DD8-4AE5-947A-16F3AF3A8715'             ,'Épuration des logs'             ,         0             ,         0             ,null             ,'fr-CA'             ,'2009-04-02 16:16:18.487'             ,'sa'             ,'2009-04-02 16:16:18.487'             ,'sa'             )  END


--Ajout de la page de visualisation des sécurités
IF NOT EXISTS( SELECT NULL  FROM medianamik_Node where NodeId = 'CF3D6A87-F011-406A-ADE7-CDCD87CF2981')  BEGIN  INSERT INTO [dbo].[medianamik_Node]             ([NodeId]             ,[ParentNodeId]             ,[ContentNodeId]             ,[TypeId]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             ,[Flags]             ,[IsDeleted]             ,[Path]             ,[Depth]             ,[Position]             ,[Roles])       VALUES             ('CF3D6A87-F011-406A-ADE7-CDCD87CF2981'             ,'7A6A4803-1D66-40F5-8DAB-76AFDAE93CF0'             ,NULL             ,'3DAD4D08-B9BC-4603-A8DE-42A88A354B5B'             ,'2009-03-24 15:01:41.213'             ,'sa'             ,'2009-03-24 15:01:41.213'             ,'sa'             ,         0             ,         0             ,'.7A6A4803-1D66-40F5-8DAB-76AFDAE93CF0.CF3D6A87-F011-406A-ADE7-CDCD87CF2981.'             ,         1             ,         1             ,'')  END
IF NOT EXISTS(SELECT NULL FROM Medianamik_NodeInstance WHERE NodeId = 'CF3D6A87-F011-406A-ADE7-CDCD87CF2981' AND CultureNAme = 'en-CA')  BEGIN  INSERT INTO [dbo].[medianamik_NodeInstance]             ([NodeInstanceId]             ,[NodeId]             ,[IsActive]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             ,[CultureName])       VALUES             ('04C21793-7698-4758-99EF-98C62A525DA6'             ,'CF3D6A87-F011-406A-ADE7-CDCD87CF2981'             ,         1             ,'2009-03-24 15:01:41.213'             ,'sa'             ,'2009-03-24 15:01:41.213'             ,'sa'             ,'en-CA')  END
IF NOT EXISTS(SELECT NULL FROM Medianamik_NodeInstance WHERE NodeId = 'CF3D6A87-F011-406A-ADE7-CDCD87CF2981' AND CultureNAme = 'fr-CA')  BEGIN  INSERT INTO [dbo].[medianamik_NodeInstance]             ([NodeInstanceId]             ,[NodeId]             ,[IsActive]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             ,[CultureName])       VALUES             ('D88A22D0-5F76-4D37-8BB0-C8FF98ADDA0F'             ,'CF3D6A87-F011-406A-ADE7-CDCD87CF2981'             ,         1             ,'2009-03-24 15:01:41.213'             ,'sa'             ,'2009-03-24 15:01:41.213'             ,'sa'             ,'fr-CA')  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = 'CF3D6A87-F011-406A-ADE7-CDCD87CF2981' AND PropertyId = 'A5F1D87F-3086-4CEA-A983-A09D4FE9FC4C' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'CF3D6A87-F011-406A-ADE7-CDCD87CF2981'             ,'A5F1D87F-3086-4CEA-A983-A09D4FE9FC4C'             ,'53d05866-f126-4875-a658-c8054cfdaee2'             ,         0             ,         0             ,null             ,''             ,'2009-03-24 15:01:41.213'             ,'sa'             ,'2009-03-24 15:02:27.047'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = 'CF3D6A87-F011-406A-ADE7-CDCD87CF2981' AND PropertyId = '47096ACE-4C51-4C8F-BAE2-15A6FD90F6E9' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'CF3D6A87-F011-406A-ADE7-CDCD87CF2981'             ,'47096ACE-4C51-4C8F-BAE2-15A6FD90F6E9'             ,'/modalwindows/securitypreviewwindow.aspx'             ,         0             ,         0             ,null             ,''             ,'2009-03-24 15:01:41.213'             ,'sa'             ,'2009-03-24 15:02:27.047'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = 'CF3D6A87-F011-406A-ADE7-CDCD87CF2981' AND PropertyId = '29571C7C-3B7A-4576-8BB0-F2EAF8413D20' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'CF3D6A87-F011-406A-ADE7-CDCD87CF2981'             ,'29571C7C-3B7A-4576-8BB0-F2EAF8413D20'             ,'False'             ,         0             ,         0             ,null             ,''             ,'2009-03-24 15:01:41.213'             ,'sa'             ,'2009-03-24 15:02:27.047'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = 'CF3D6A87-F011-406A-ADE7-CDCD87CF2981' AND PropertyId = 'A9D96D60-4E0D-4EF6-831C-AAD02A1D2BCF' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'CF3D6A87-F011-406A-ADE7-CDCD87CF2981'             ,'A9D96D60-4E0D-4EF6-831C-AAD02A1D2BCF'             ,'True'             ,         0             ,         0             ,null             ,''             ,'2009-03-24 15:01:41.213'             ,'sa'             ,'2009-03-24 15:02:27.047'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = 'CF3D6A87-F011-406A-ADE7-CDCD87CF2981' AND PropertyId = '7213C44C-BBC7-4095-AE52-0DE37E7276C7' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'CF3D6A87-F011-406A-ADE7-CDCD87CF2981'             ,'7213C44C-BBC7-4095-AE52-0DE37E7276C7'             ,'False'             ,         0             ,         0             ,null             ,''             ,'2009-03-24 15:01:41.213'             ,'sa'             ,'2009-03-24 15:02:27.047'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = 'CF3D6A87-F011-406A-ADE7-CDCD87CF2981' AND PropertyId = '60C0AA24-C355-4722-ACAA-21D363351479' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'CF3D6A87-F011-406A-ADE7-CDCD87CF2981'             ,'60C0AA24-C355-4722-ACAA-21D363351479'             ,NULL             ,         0             ,         0             ,null             ,''             ,'2009-03-24 15:01:41.213'             ,'sa'             ,'2009-03-24 15:02:27.047'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = 'CF3D6A87-F011-406A-ADE7-CDCD87CF2981' AND PropertyId = '18232ABC-5DD8-4AE5-947A-16F3AF3A8715' AND CultureName = 'en-CA' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'CF3D6A87-F011-406A-ADE7-CDCD87CF2981'             ,'18232ABC-5DD8-4AE5-947A-16F3AF3A8715'             ,'Group Security Visualization'             ,         0             ,         0             ,null             ,'en-CA'             ,'2009-03-24 15:01:41.213'             ,'sa'             ,'2009-03-24 15:02:27.047'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = 'CF3D6A87-F011-406A-ADE7-CDCD87CF2981' AND PropertyId = '18232ABC-5DD8-4AE5-947A-16F3AF3A8715' AND CultureName = 'fr-CA' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'CF3D6A87-F011-406A-ADE7-CDCD87CF2981'             ,'18232ABC-5DD8-4AE5-947A-16F3AF3A8715'             ,'Visualisation de la sécurité d''un groupe'             ,         0             ,         0             ,null             ,'fr-CA'             ,'2009-03-24 15:01:41.213'             ,'sa'             ,'2009-03-24 15:02:27.047'             ,'sa'             )  END

--Ajout de la page de gestion des revisions
IF NOT EXISTS( SELECT NULL  FROM medianamik_Node where NodeId = 'B8DD9D17-E931-4678-B3E2-442293A379E5')  BEGIN  INSERT INTO [dbo].[medianamik_Node]             ([NodeId]             ,[ParentNodeId]             ,[ContentNodeId]             ,[TypeId]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             ,[Flags]             ,[IsDeleted]             ,[Path]             ,[Depth]             ,[Position]             ,[Roles])       VALUES             ('B8DD9D17-E931-4678-B3E2-442293A379E5'             ,'7A6A4803-1D66-40F5-8DAB-76AFDAE93CF0'             ,NULL             ,'3DAD4D08-B9BC-4603-A8DE-42A88A354B5B'             ,'2009-03-27 14:51:02.907'             ,'sa'             ,'2009-03-27 14:51:02.907'             ,'sa'             ,         0             ,         0             ,'.7A6A4803-1D66-40F5-8DAB-76AFDAE93CF0.B8DD9D17-E931-4678-B3E2-442293A379E5.'             ,         1             ,         0             ,'')  END
IF NOT EXISTS(SELECT NULL FROM Medianamik_NodeInstance WHERE NodeId = 'B8DD9D17-E931-4678-B3E2-442293A379E5' AND CultureNAme = 'fr-CA')  BEGIN  INSERT INTO [dbo].[medianamik_NodeInstance]             ([NodeInstanceId]             ,[NodeId]             ,[IsActive]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             ,[CultureName])       VALUES             ('4B3FAD17-C07D-4939-9C72-09380CD23EB0'             ,'B8DD9D17-E931-4678-B3E2-442293A379E5'             ,         1             ,'2009-03-27 14:51:02.907'             ,'sa'             ,'2009-03-27 14:51:02.907'             ,'sa'             ,'fr-CA')  END
IF NOT EXISTS(SELECT NULL FROM Medianamik_NodeInstance WHERE NodeId = 'B8DD9D17-E931-4678-B3E2-442293A379E5' AND CultureNAme = 'en-CA')  BEGIN  INSERT INTO [dbo].[medianamik_NodeInstance]             ([NodeInstanceId]             ,[NodeId]             ,[IsActive]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             ,[CultureName])       VALUES             ('3161370E-1CC6-4E84-9CF9-B277D336571E'             ,'B8DD9D17-E931-4678-B3E2-442293A379E5'             ,         1             ,'2009-03-27 14:51:02.907'             ,'sa'             ,'2009-03-27 14:51:02.907'             ,'sa'             ,'en-CA')  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = 'B8DD9D17-E931-4678-B3E2-442293A379E5' AND PropertyId = '7213C44C-BBC7-4095-AE52-0DE37E7276C7' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'B8DD9D17-E931-4678-B3E2-442293A379E5'             ,'7213C44C-BBC7-4095-AE52-0DE37E7276C7'             ,'False'             ,         0             ,         0             ,null             ,''             ,'2009-03-27 14:51:02.907'             ,'sa'             ,'2009-04-06 16:03:38.730'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = 'B8DD9D17-E931-4678-B3E2-442293A379E5' AND PropertyId = '29571C7C-3B7A-4576-8BB0-F2EAF8413D20' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'B8DD9D17-E931-4678-B3E2-442293A379E5'             ,'29571C7C-3B7A-4576-8BB0-F2EAF8413D20'             ,'False'             ,         0             ,         0             ,null             ,''             ,'2009-03-27 14:51:02.907'             ,'sa'             ,'2009-04-06 16:03:38.730'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = 'B8DD9D17-E931-4678-B3E2-442293A379E5' AND PropertyId = 'A5F1D87F-3086-4CEA-A983-A09D4FE9FC4C' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'B8DD9D17-E931-4678-B3E2-442293A379E5'             ,'A5F1D87F-3086-4CEA-A983-A09D4FE9FC4C'             ,'f091e77f-76db-421b-87ab-8ad4c2155175'             ,         0             ,         0             ,null             ,''             ,'2009-03-27 14:51:02.907'             ,'sa'             ,'2009-04-06 16:03:38.730'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = 'B8DD9D17-E931-4678-B3E2-442293A379E5' AND PropertyId = 'A9D96D60-4E0D-4EF6-831C-AAD02A1D2BCF' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'B8DD9D17-E931-4678-B3E2-442293A379E5'             ,'A9D96D60-4E0D-4EF6-831C-AAD02A1D2BCF'             ,'True'             ,         0             ,         0             ,null             ,''             ,'2009-03-27 14:51:02.907'             ,'sa'             ,'2009-04-06 16:03:38.730'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = 'B8DD9D17-E931-4678-B3E2-442293A379E5' AND PropertyId = '47096ACE-4C51-4C8F-BAE2-15A6FD90F6E9' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'B8DD9D17-E931-4678-B3E2-442293A379E5'             ,'47096ACE-4C51-4C8F-BAE2-15A6FD90F6E9'             ,'/revisionmanagement.aspx'             ,         0             ,         0             ,null             ,''             ,'2009-03-27 14:51:02.907'             ,'sa'             ,'2009-04-06 16:03:38.730'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = 'B8DD9D17-E931-4678-B3E2-442293A379E5' AND PropertyId = '60C0AA24-C355-4722-ACAA-21D363351479' AND CultureName = '' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'B8DD9D17-E931-4678-B3E2-442293A379E5'             ,'60C0AA24-C355-4722-ACAA-21D363351479'             ,'796a2401-7be9-44fa-b079-848e90afe0e7'             ,         0             ,         0             ,null             ,''             ,'2009-03-27 14:51:02.907'             ,'sa'             ,'2009-04-06 16:03:38.730'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = 'B8DD9D17-E931-4678-B3E2-442293A379E5' AND PropertyId = '18232ABC-5DD8-4AE5-947A-16F3AF3A8715' AND CultureName = 'en-CA' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'B8DD9D17-E931-4678-B3E2-442293A379E5'             ,'18232ABC-5DD8-4AE5-947A-16F3AF3A8715'             ,'Revision Management'             ,         0             ,         0             ,null             ,'en-CA'             ,'2009-03-27 14:51:02.907'             ,'sa'             ,'2009-04-06 16:03:38.730'             ,'sa'             )  END
IF NOT EXISTS( SELECT NULL FROM medianamik_NodePropertyValue where NodeId = 'B8DD9D17-E931-4678-B3E2-442293A379E5' AND PropertyId = '18232ABC-5DD8-4AE5-947A-16F3AF3A8715' AND CultureName = 'fr-CA' AND Revision IS NULL)  BEGIN  INSERT INTO [dbo].[medianamik_NodePropertyValue]             ([NodePropertyValueId]             ,[NodeId]             ,[PropertyId]             ,[Value]             ,[IsApproved]             ,[IsDeleted]             ,[Revision]             ,[CultureName]             ,[CreatedOn]             ,[CreatedBy]             ,[ModifiedOn]             ,[ModifiedBy]             )       VALUES             (NEWID()             ,'B8DD9D17-E931-4678-B3E2-442293A379E5'             ,'18232ABC-5DD8-4AE5-947A-16F3AF3A8715'             ,'Gestion des revisions'             ,         0             ,         0             ,null             ,'fr-CA'             ,'2009-03-27 14:51:02.907'             ,'sa'             ,'2009-04-06 16:03:38.730'             ,'sa'             )  END

--Correction d'un bug sur la table ActivityLog
ALTER TABLE dbo.medianamik_ActivityLog ALTER COLUMN IP varchar(39) NULL

